import matplotlib.pyplot as plt
from datetime import date
import csv

x = []

with open('result.csv', newline='') as f:
    reader = csv.reader(f)
    data = list(reader)

nrows, ncols = len(data), len(data[0])

y = [[] for _ in range(ncols-1)]

full_str = data[1][0].split("-")
day_str = full_str[0].split("/")
sec_str = full_str[1].split(":")
start_date = date(int(day_str[0]), int(day_str[1]), int(day_str[2]))
start_sec = int(sec_str[0]) * 60 * 60 + int(sec_str[1]) * 60 + int(sec_str[2])


def get_time(time_str_in):
    time_str = time_str_in.split("-")
    day_str = time_str[0].split("/")
    sec_str = time_str[1].split(":")
    days = (date(int(day_str[0]), int(day_str[1]), int(day_str[2])) - start_date).days
    secs = int(sec_str[0]) * 60 * 60 + int(sec_str[1]) * 60 + int(sec_str[2]) - start_sec
    secs += days * 24 * 60 * 60
    return secs/3600

for row in range(1, nrows):
    x.append(get_time(data[row][0]))

for column in range(1, ncols):
    for row in range(1, nrows):
        y[column-1].append(int(data[row][column]))

for i in range(len(y)):
    plt.subplot(6, 7, i+1)
    plt.plot(x, y[i])
    plt.ylim(0, 50)
    plt.xlim(0, 168)
    if i+1 == 19:
        plt.title("19 - cheat")
    else:
        plt.title(str(i+1))
    plt.grid()

plt.subplots_adjust(left=0.026, bottom=0.029, right=1, top=0.952, wspace=0.27, hspace=0.63)
plt.show()
